

package com.developerlife.myservice;

import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Binder;
import android.os.IBinder;
import android.widget.Toast;

public class LocalService extends Service {
    private NotificationManager mNM;
    MediaPlayer mMediaPlayer;
    private final IBinder mBinder = new LocalBinder();
    public class LocalBinder extends Binder {
        LocalService getService() {
            return LocalService.this;
        }
    }
    
    @Override
    public void onCreate() {    	
        mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    }

	@Override
    public void onDestroy() {
        mNM.cancel(R.string.local_service_started);       
        Toast.makeText(this, R.string.local_service_stopped, Toast.LENGTH_SHORT).show();
    }
	
    public void startMp3Player() {
    	mMediaPlayer = MediaPlayer.create(getApplicationContext(), 
                R.raw.abc);
    	mMediaPlayer.start(); 
    }
    
    public void mp3Stop() {
    	mMediaPlayer.stop();
    	mMediaPlayer.release();
    }
    
    @Override
    public IBinder onBind(Intent intent) {    	    	
        return mBinder;
    }
   
}

